import { createI18n } from "vue-i18n";
import mZhLocale from "./zh";
import mEnLocale from "./en";
import store from "@/store";
const messages = {
  en: {
    ...mEnLocale,
  },
  zh: {
    ...mZhLocale,
  },
};
// 进行持久化处理，防止在页面刷新之后数据丢失
const getLanguage = () => {
  return store && store.getters && store.getters.language;
};

const i18n = createI18n({
  legacy: false,
  locale: getLanguage(),
  globalInjection: true,
  messages,
});

export default i18n;